package com.iwdnb.gkgz.application.kline;

import java.util.ArrayList;
import java.util.List;

import com.iwdnb.bmnf.common.enums.CodeMessage;
import com.iwdnb.bmnf.common.utils.ApplicationContextUtils;
import org.apache.commons.lang3.StringUtils;

public enum ShapeEnum implements CodeMessage {

    HAMMER("hammer", "锤子线", "buy"),
    INVERT_HAMMER("invertHammer", "锤子线", "sell"),
    LOW_NINE_TURN("lowNineTurn", "低九", "buy"),
    HIGH_NINE_TURN("highNineTurn", "高九", "sell"),
    LOW_RANGE_PRICE("lowRangePrice", "波段低价", "buy"),
    LOW_PRICE_BOLLING_BIAS("lowPriceAndBollingAndBias", "低价+布林下轨+乖离率", "buy"),

    ;
    private String code;
    private String message;
    private String type;

    ShapeEnum(String code, String message, String type) {
        this.code = code;
        this.message = message;
        this.type = type;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public Shape getShape() {
        return ApplicationContextUtils.getBean(code);
    }

    public String getType() {
        return type;
    }

    public static List<ShapeEnum> getListByType(String type) {
        List<ShapeEnum> shapeEnums = new ArrayList<>();
        for (ShapeEnum shapeEnum : ShapeEnum.values()) {
            if (StringUtils.equals(shapeEnum.getType(), type)) {
                shapeEnums.add(shapeEnum);
            }
        }
        return shapeEnums;
    }
}
